package com.xinzhi.savingpot.configure;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Created by bianxh on 2020/11/25.
 */
@Configuration
@EnableSwagger2  //开启配置
public class SwaggerApp {

    /**
     * 添加摘要信息(Docket)
     */
    @Bean
    public Docket controllerApi() {
        //创建Docket关联apiInfo
        //配置Swagger的Docket的bean实例
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title("摇钱树_任务管理_接口文档")
                        .description("用于管理任务信息...")
                        .contact(new Contact("悠哉的程序猿", null, null))
                        .version("版本号:1.0")
                        .build())
                .select()
                //RequestHandlerSelectors:配置要扫描接口的方式
                //basePackage:指定要扫描的包
                //any()扫描全部 none()不扫描
                .apis(RequestHandlerSelectors.basePackage("com.xinzhi.savingpot"))
                //过滤某路径 还可以通过正则表达式进行控制
                .paths(PathSelectors.any())
                .build();
    }

}